package com.pdg.dungeondelver.defaulttheme.builders;

import com.pdg.dungeondelver.client.constants.BuilderConstants;
import com.pdg.dungeondelver.client.constants.GameConstants;
import com.pdg.dungeondelver.client.constants.PropertyGroupConstants;
import com.pdg.dungeondelver.engine.AtlasCell;
import com.pdg.dungeondelver.engine.AtlasCellBuilder;
import com.pdg.dungeondelver.engine.AtlasColumn;
import com.pdg.dungeondelver.engine.LayerBuilder;

public class DefaultAtlasCellBuilder implements AtlasCellBuilder{

	@Override
	public AtlasCell build(AtlasColumn theAtlasColumn) {
		AtlasCell atlasCell = new AtlasCell(theAtlasColumn);
		Integer depth = theAtlasColumn.getConfiguration().getPropertyGroups().get(PropertyGroupConstants.GAME_CONSTANTS).<Integer>get(GameConstants.ATLAS_DEPTH);
		LayerBuilder builder = theAtlasColumn.getConfiguration().getPropertyGroups().get(PropertyGroupConstants.BUILDERS).<LayerBuilder>get(BuilderConstants.LAYER_BUILDER);
		for(Integer index=0;index<depth;++index){
			atlasCell.put(index, builder.build(atlasCell));
		}
		return atlasCell;
	}

}
